-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REVIEW] install cmake config file with RMM #580
Conversation
This doesn't change behavior by default, but it does allow, e.g., distro package managers to impose their own directory structure. (And it's not really GNU specific)
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
If RMM is used in a downstream project via `find_package(rmm)`, it'll provide the namespaced rmm::rmm target. If it's used via `add_subdirectory()` it creates its usual `rmm` target, but with this change it creates an `rmm::rmm` alias, too.
Could someone say "ok to test"? ;) |
Ok to test |
Can we look into using |
I looked at it. It doesn't quite work, once Thrust is added, since it assumes it can just do a bunch of We could possibly submit PRs to |
Co-authored-by: Keith Kraus <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Just suggesting some streamlining of the (already very nice) docs you added, such as converting future tense to present tense for clarity.
Co-authored-by: Keith Kraus <[email protected]> Co-authored-by: Mark Harris <[email protected]>
Oops, I just found this comment I wrote in github a couple of days ago, but apparently never actually submitted. So it's time to talk about the caveats. First of all, the potential for breaking something that currently works is fairly low. Essentially, this PR only adds some new cmake config files that are installed alongside rmm's headers. But there are some complications related to thrust: Currently, the installed target does depend on So that's why it's WIP, it's only actually usable by a downstream project if the downstream project hacks around this limitation. I think there are two options to handle this:
Option 1 would make things work without trouble for the typical downstream project. They'd likely end up using the thrust installed with their CUDA toolkit, which is probably good enough for them. If they do care about a newer thrust, they'd pull that in explicitly, and it'd get used. Option 2 is the more correct way of doing things, but it also makes it harder to actually use rmm via
I'm kinda ambivalent about what the best way to proceed is. One could choose option 1 for now and switch to doing things properly once a new version of thrust is released (or once the PRs above are merged, depend on a specific version from thrust's FWIW, this is the diff for option 2: diff --git a/cmake/RMM_thirdparty.cmake b/cmake/RMM_thirdparty.cmake
index 319d031..ab5abbc 100644
--- a/cmake/RMM_thirdparty.cmake
+++ b/cmake/RMM_thirdparty.cmake
@@ -23,6 +23,10 @@ CPMFindPackage(
GIT_TAG 1.10.0
VERSION 1.10.0
GIT_SHALLOW TRUE
+ OPTIONS
+ # If there is no pre-installed thrust we can use, we'll install our fetched copy
+ # together with RMM
+ "THRUST_INSTALL TRUE"
)
thrust_create_target(rmm::Thrust FROM_OPTIONS)
diff --git a/rmm-config.cmake.in b/rmm-config.cmake.in
index a720acf..617828f 100644
--- a/rmm-config.cmake.in
+++ b/rmm-config.cmake.in
@@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.17)
include(CMakeFindDependencyMacro)
find_dependency(CUDAToolkit)
find_dependency(spdlog 1.7.0)
+find_dependency(Thrust 1.10.0)
+thrust_create_target(rmm::Thrust FROM_OPTIONS)
include("${CMAKE_CURRENT_LIST_DIR}/rmm-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/rmm-config-version.cmake") Option 1 would be simply going to back to using |
@harrism, I committed all of your suggested doc changes, btw -- thanks! |
Just FYI, I think RMM should work fine with thrust 1.9.x. HOWEVER, libcudf needs Thrust 1.10+ I think and the most common use cases of RMM also use cuDF. |
So given the timeframe for the next release, I'm inclined to address the last little hitch that I'm aware of in this PR as well (besides finishing the thrust issue): Right now, RMM does this: if(USE_NVTX)
message(STATUS "Using Nvidia Tools Extension")
else()
target_compile_definitions(rmm INTERFACE NVTX_DISABLE)
endif(USE_NVTX) By default, So this flag is something that maybe should be set for the benchmarks, but not generally for RMM and all of its consumers. Right now, it really doesn't need to be set at all, since I believe no nvtx is used anywhere at all. An easy solution would be to get rid of the above, since it isn't even being used. That would also allow to reintroduce it later as |
You can remove the NVTX stuff. I have an open PR that I plan to update in the next release to add some NVTX regions and I can add a new flag there if necessary. |
Note that while burndown means "no new PRs", we still have about a week during burndown to finish in progress PRs. |
trying to keep things clean...
Not sure that all versions that float around on the internet are the same, this is from Kitware/VTK.
This should cover all the bases.
cmake/install/FindThrust.cmake
Outdated
## Copyright (c) Kitware, Inc. | ||
## All rights reserved. | ||
## See LICENSE.txt for details. | ||
## This software is distributed WITHOUT ANY WARRANTY; without even | ||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
## PURPOSE. See the above copyright notice for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the license for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a good point. I guess it's this: https://gitlab.kitware.com/vtk/vtk-m/-/blob/783867eeb05e0a6538f9c520af02c3615651b4ed/LICENSE.txt. It does say
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.
* Neither the name of Kitware nor the names of any contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
So it seems pretty permissive, but IANAL.
I can write a custom one from scratch if this causes issues. Chances are it would look very similar, though, since really, the only thing that is not boilerplate in there is the version parsing, and that comes from Nvidia.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the BSD 3-clause license plus extra non-exclusive licenses from US govt labs and extra copyrights. That is one of the licenses we can easily use. We still have a process we need to follow to add a new piece of software. I will check if RAPIDS already has done this for CMake code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, we have approval, but before we can merge we need the complete license for this file included (ideally in this file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so I copied in the full text from the LICENSE.txt above.
Yeah, I understand, that's why I didn't want to come with a little follow-up PR later. The latest push now removes There's some asymmetry in that we required Thrust >= 1.10.0 at build time (and fetch if necessary), but accept Thrust >= 1.9.0 when using the installed RMM. I think that's reasonable for the time being, though. I didn't leave a warning if Thrust < 1.10 ends up being used, but I can easily add one back if desired. When cmake finds an old Thrust version it will show what version it is, and its location, so it's at least somewhat visible in any case:
RMM will prefer a newer Thrust, found by config mode, though, before falling back to the old way. There's a bit of a similar issue to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved pending the license question
I just noticed that in an earlier commit you modified FindThrust.cmake, rather than just pulling it in without changes. That changes the process. I would have to start over with a much more involved legal process. Any chance of using the original unmodified FindThrust? (Or getting Thrust to provide their own?) Or somehow not needing FindThrust? (We didn't need it previously...) |
This one now tries to find an install Thrust config first, and if it's not found, it looks for Thrust itself, and also provides a compatibility `thrust_create_target()` function.
I started over and implemented a
Well, a prior revision of this PR was like that, if a newer Thrust wasn't found by config, it'd just keep its fingers crossed that some other thrust would be found automatically at build time (which would usually work, since it's in the cuda toolkit). But I think what's there now is cleaner, and at some point in the future, when Thrust that comes with its own cmake config is commonly available, the It's worth noting that this |
This is fantastic. Thanks very much for doing this. It's not that we couldn't use the VTK-m code, its just that I have to go through a different process with the lawyers if we plan to modify it. BTW, if you ever want to discuss anything not directly related to a PR off of github, you can find us on the RAPIDS public slack linked from this page: https://rapids.ai/community.html |
@kkraus14 you might want to have a look before we merge? |
supersedes #462 -- a lot of cmake stuff has changed since, so it makes sense to do this over.
This PR first switches to using
GNUInstallDirs
to determine paths where to write includes / libraries. This doesn't change existing behavior, but it does make it easier for, e.g., distros to set custom install paths.The main thing, though, is that it adds
rmm-config.cmake
and friends that allow for easier consumption of RMM in downstream projects, ie.,This PR does not yet handle the thirdparty dependency on thrust -- I'll add that after #579 is resolved. It does, however, handle the dependency on spdlog, which serves as an example on how thirdparty are handled:
Since RMM is now using CPM, there are two cases, depending on whether spdlog is present. In either case, the
rmm::rmm
target will records its dependency on spdlog (as well as cudart and thrust), which has to be resolved when pulling in the package viafind_package
as above.spdlog is found as a locally installed package (e.g., installed through conda). In this case, the spdlog dependency is resolved through a
find_dependency(spdlog 1.17.0)
which happens automatically inside of thefind_package()
call above. This assumes that spdlog is installed on the system where the installed RMM is used (and will error if no spdlog can be found).spdlog was not locally installed, so RMM pulled in spdlog via
FetchContent
. In this case, since a downstream user needs to have spdlog in order to (fully) use RMM, spdlog is installed together with RMM onmake install
. The downstream app will end up using RMM and its bundled spdlog.This does change existing behavior in the 2nd case in that spdlog is built and installed together with RMM. It should not break anything, but takes some additional build time. Hitting the 2nd case should be rare, though -- when using, e.g., conda, spdlog will be available and one will hit case 1, where existing behavior does not change (except for installing a few additional cmake config files).